package com.ss.android.article.common.share.entry;

import android.os.Parcel;
import android.os.Parcelable;

import com.bytedance.common.utility.collection.e;
import com.ss.android.common.AbsApiThread;

import java.util.concurrent.atomic.AtomicInteger;

import org.json.JSONObject;

public class EntryItem implements Parcelable {
    public static final Parcelable.Creator CREATOR = new Creator<EntryItem>() {

        @Override
        public EntryItem createFromParcel(Parcel source) {
            return new EntryItem(source);
        }

        @Override
        public EntryItem[] newArray(int size) {
            return new EntryItem[size];
        }
    };
    public static final int TYPE_CATEGORY = 2;
    public static final int TYPE_CITY = 3;
    public static final int TYPE_PGC_MEDIA = 1;
    public static final int TYPE_TOPIC = 4;
    public static final int TYPE_WAP = 5;
    public String mDescription;
    public long mGroupId;
    public String mIconUrl;
    public final long mId;
    private transient boolean mIdOnly;
    public transient boolean mIsLoading;
    public String mLabel;
    public int mLabelStyle;
    public String mName;
    public int mPosition;
    public String mShareUrl;
    public boolean mShowNewTip;
    private transient int mSubTag;
    public int mSubscribeCount;
    private boolean mSubscribed;
    public int mType;
    public String mWapUrl;
    private static e<Long,EntryItem> sEntryMapCache = new e<>();
    private static AtomicInteger sSubTagGlobal = new AtomicInteger();

    private EntryItem(long arg4, boolean arg6) {
        this.mPosition = -1;
        this.mIsLoading = false;
        this.mSubTag = 0;
        this.mIdOnly = false;
        this.mId = arg4;
        this.mSubTag = EntryItem.sSubTagGlobal.get();
        this.mIdOnly = arg6;
    }

    protected EntryItem(Parcel arg7) {
        boolean v1 = true;
        this.mPosition = -1;
        this.mIsLoading = false;
        this.mSubTag = 0;
        this.mIdOnly = false;
        this.mId = arg7.readLong();
        this.mType = arg7.readInt();
        this.mName = arg7.readString();
        this.mDescription = arg7.readString();
        this.mIconUrl = arg7.readString();
        this.mSubscribeCount = arg7.readInt();
        boolean v0 = arg7.readByte() != 0 ? true : false;
        this.mSubscribed = v0;
        if (arg7.readByte() == 0) {
            v1 = false;
        }

        this.mShowNewTip = v1;
        this.mWapUrl = arg7.readString();
        this.mGroupId = arg7.readLong();
        this.mPosition = arg7.readInt();
        this.mShareUrl = arg7.readString();
        this.mLabelStyle = arg7.readInt();
        this.mLabel = arg7.readString();
    }

    public static void clearAllSubscribeFlag() {
        EntryItem.sSubTagGlobal.incrementAndGet();
    }

    public int describeContents() {
        return 0;
    }

    public boolean equals(Object arg7) {
        boolean v0 = true;
        if (this != (((EntryItem) arg7))) {
            if (arg7 == null) {
                v0 = false;
            } else if (this.getClass() != arg7.getClass()) {
                v0 = false;
            } else if (this.mId != ((EntryItem) arg7).mId) {
                v0 = false;
            }
        }

        return v0;
    }

    public void extractFields(JSONObject arg3) {
        if (arg3 != null) {
            this.mType = arg3.optInt("type");
            this.mName = arg3.optString("name");
            this.mDescription = arg3.optString("description");
            this.mIconUrl = arg3.optString("icon");
            this.mSubscribeCount = arg3.optInt("subscribe_count");
            this.setSubscribed(AbsApiThread.optBoolean(arg3, "is_subscribed", false));
            this.mShowNewTip = AbsApiThread.optBoolean(arg3, "tip_new", false);
            this.mGroupId = arg3.optLong("group_id");
            this.mWapUrl = arg3.optString("url");
            this.mPosition = arg3.optInt("index", -1);
            this.mLabel = arg3.optString("label");
            this.mLabelStyle = arg3.optInt("label_style");
            this.mShareUrl = arg3.optString("share_url");
        }
    }

    public static EntryItem getFake(long arg2) {
        return new EntryItem(arg2, true);
    }

    public int hashCode() {
        return (((int) (this.mId ^ this.mId >>> 32))) + 31;
    }

    public boolean isIdOnly() {
        return this.mIdOnly;
    }

    public boolean isSubscribed() {
        boolean v0 = !this.mSubscribed || this.mSubTag != EntryItem.sSubTagGlobal.get() ? false : true;
        return v0;
    }

    public static EntryItem obtain(long arg4) {
        Class v1 = EntryItem.class;
        Object v0_1 = null;
        synchronized (v1) {
            v0_1 = EntryItem.sEntryMapCache.a(Long.valueOf(arg4));
            if (v0_1 == null) {
                v0_1 = new EntryItem(arg4, false);
                EntryItem.sEntryMapCache.a(Long.valueOf(arg4), v0_1);
            }
        }
        return (EntryItem) v0_1;
    }

    public static EntryItem optObtain(long arg4) {
        Class v1 = EntryItem.class;
        synchronized (v1) {
            return (EntryItem) EntryItem.sEntryMapCache.a(Long.valueOf(arg4));
        }
    }

    public void setSubscribed(boolean arg3) {
        this.mSubscribed = arg3;
        if (this.mSubTag != EntryItem.sSubTagGlobal.get()) {
            this.mSubTag = EntryItem.sSubTagGlobal.get();
        }
    }

    public String toString() {
        return "EntryItem [mId=" + this.mId + ", mType=" + this.mType + ", mName=" + this.mName + ", mDescription=" + this.mDescription + ", mIconUrl=" + this.mIconUrl + ", mSubscribeCount=" + this.mSubscribeCount + ", mSubscribed=" + this.mSubscribed + ", mShowNewTip=" + this.mShowNewTip + ", mPosition=" + this.mPosition + ", mIsLoading=" + this.mIsLoading + ", mLabelStyle=" + this.mLabelStyle + ", mLabel=" + this.mLabel + "]";
    }

    public void writeToParcel(Parcel arg7, int arg8) {
        int v1 = 1;
        arg7.writeLong(this.mId);
        arg7.writeInt(this.mType);
        arg7.writeString(this.mName);
        arg7.writeString(this.mDescription);
        arg7.writeString(this.mIconUrl);
        arg7.writeInt(this.mSubscribeCount);
        int v0 = this.mSubscribed ? 1 : 0;
        arg7.writeByte(((byte) v0));
        if (!this.mShowNewTip) {
            v1 = 0;
        }

        arg7.writeByte(((byte) v1));
        arg7.writeString(this.mWapUrl);
        arg7.writeLong(this.mGroupId);
        arg7.writeInt(this.mPosition);
        arg7.writeString(this.mShareUrl);
        arg7.writeInt(this.mLabelStyle);
        arg7.writeString(this.mLabel);
    }
}

